package com.telchina.workorder.controller;

import java.util.List;

import com.telchina.common.annotation.Log;
import com.telchina.common.core.controller.BaseController;
import com.telchina.common.core.domain.AjaxResult;
import com.telchina.common.enums.BusinessType;
import com.telchina.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.telchina.workorder.domain.WoCxjsw;
import com.telchina.workorder.service.IWoCxjswService;

/**
 * 数据对接中间Controller
 *
 * @author konghao
 * @date 2023-03-27
 */
@RestController
@RequestMapping("/workorder/woCxjsw")
public class WoCxjswController extends BaseController {
    @Autowired
    private IWoCxjswService woCxjswService;

    /**
     * 分页查询数据对接中间列表
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:list')")
    @GetMapping("/list")
    public AjaxResult list(WoCxjsw woCxjsw) {
        startPage();
        List<WoCxjsw> list = woCxjswService.selectListAll(woCxjsw);
//        IPage<WoCxjsw> list = woCxjswService.selectList(startPage(), woCxjsw);
        return getDataTable(list);
    }

    /**
     * 查询数据对接中间列表
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:list')")
    @GetMapping("/list/all")
    public AjaxResult listAll(WoCxjsw woCxjsw) {
        List<WoCxjsw> list = woCxjswService.selectListAll(woCxjsw);
        return AjaxResult.success(list);
    }

    /**
     * 导出数据对接中间列表
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:export')")
    @Log(title = "数据对接中间" , businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WoCxjsw woCxjsw) {
        List<WoCxjsw> list = woCxjswService.selectListAll(woCxjsw);
        ExcelUtil<WoCxjsw> util = new ExcelUtil<WoCxjsw>(WoCxjsw.class);
        return util.exportExcel(list, "cxjsw");
    }

    /**
     * 获取数据对接中间详细信息
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid) {
        return AjaxResult.success(woCxjswService.selectById(guid));
    }

    /**
     * 新增数据对接中间
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:add')")
    @Log(title = "数据对接中间" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WoCxjsw woCxjsw) {
        return toAjax(woCxjswService.insert(woCxjsw));
    }

    /**
     * 修改数据对接中间
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:edit')")
    @Log(title = "数据对接中间" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WoCxjsw woCxjsw) {
        return toAjax(woCxjswService.update(woCxjsw));
    }

    /**
     * 删除数据对接中间
     */
//    @PreAuthorize("@ss.hasPermi('workOrder:cxjsw:remove')")
    @Log(title = "数据对接中间" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(woCxjswService.deleteByIds(guids));
    }
}
